package org.gingresosapi.persistencia;

import org.gingresosapi.beans.Recibosdetallestemporal;
import java.sql.Date; 
import org.gingresosapi.beans.*;
import org.gingresosapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.gingresosapi.generales.Mensajeria;
import org.gingresosapi.generales.DataGManager;


/**
*
* @author
*/

public class RecibosdetallestemporalPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/gingresosapi/properties/mensajes");
static DataGManager dataGManager;
static List<Recibosdetallestemporal> list;

public RecibosdetallestemporalPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Recibosdetallestemporal recibosdetallestemporal ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into recibosdetallestemporal(idrecibo,idmunicipio,fecha,idregimen,dueno,valor,cantidad,pago,esrecargo,saldo,username,idrecibesdetallestemporal)  values(?,?,?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setInt(1,recibosdetallestemporal.getIdrecibo());
        pinsert.setString(2,recibosdetallestemporal.getIdmunicipio());
        pinsert.setDate(3,recibosdetallestemporal.getFecha());
        pinsert.setString(4,recibosdetallestemporal.getIdregimen());
        pinsert.setString(5,recibosdetallestemporal.getDueno());
        pinsert.setDouble(6,recibosdetallestemporal.getValor());
        pinsert.setInt(7,recibosdetallestemporal.getCantidad());
        pinsert.setDouble(8,recibosdetallestemporal.getPago());
        pinsert.setString(9,recibosdetallestemporal.getEsrecargo());
        pinsert.setDouble(10,recibosdetallestemporal.getSaldo());
        pinsert.setString(11,recibosdetallestemporal.getUsername());
        pinsert.setInt(12,recibosdetallestemporal.getIdrecibesdetallestemporal());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Recibosdetallestemporal recibosdetallestemporal ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update recibosdetallestemporal set  idrecibo=?, idmunicipio=?, fecha=?, idregimen=?, dueno=?, valor=?, cantidad=?, pago=?, esrecargo=?, saldo=?, username=?, idrecibesdetallestemporal=?  where  idrecibesdetallestemporal ='"+recibosdetallestemporal.getIdrecibesdetallestemporal()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(1,recibosdetallestemporal.getIdrecibo());
pupdate.setString(2,recibosdetallestemporal.getIdmunicipio());
pupdate.setDate(3,recibosdetallestemporal.getFecha());
pupdate.setString(4,recibosdetallestemporal.getIdregimen());
pupdate.setString(5,recibosdetallestemporal.getDueno());
pupdate.setDouble(6,recibosdetallestemporal.getValor());
pupdate.setInt(7,recibosdetallestemporal.getCantidad());
pupdate.setDouble(8,recibosdetallestemporal.getPago());
pupdate.setString(9,recibosdetallestemporal.getEsrecargo());
pupdate.setDouble(10,recibosdetallestemporal.getSaldo());
pupdate.setString(11,recibosdetallestemporal.getUsername());
pupdate.setInt(12,recibosdetallestemporal.getIdrecibesdetallestemporal());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  recibosdetallestemporal set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Recibosdetallestemporal recibosdetallestemporal_old , Recibosdetallestemporal recibosdetallestemporal) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update recibosdetallestemporal set  idrecibesdetallestemporal=?  where  idrecibesdetallestemporal ='"+recibosdetallestemporal_old.getIdrecibesdetallestemporal()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setInt(12,recibosdetallestemporal.getIdrecibesdetallestemporal());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Recibosdetallestemporal recibosdetallestemporal ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from recibosdetallestemporal  where  idrecibesdetallestemporal = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setInt(12,recibosdetallestemporal.getIdrecibesdetallestemporal());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from recibosdetallestemporal where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from recibosdetallestemporal  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Recibosdetallestemporal recibosdetallestemporal) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from recibosdetallestemporal where idrecibesdetallestemporal='"+recibosdetallestemporal.getIdrecibesdetallestemporal()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Recibosdetallestemporal findByPrimaryKey(Recibosdetallestemporal recibosdetallestemporal) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from recibosdetallestemporal where idrecibesdetallestemporal='"+recibosdetallestemporal.getIdrecibesdetallestemporal()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            recibosdetallestemporal.setIdrecibo(rs.getInt("idrecibo"));
recibosdetallestemporal.setIdmunicipio(rs.getString("idmunicipio"));
recibosdetallestemporal.setFecha(rs.getDate("fecha"));
recibosdetallestemporal.setIdregimen(rs.getString("idregimen"));
recibosdetallestemporal.setDueno(rs.getString("dueno"));
recibosdetallestemporal.setValor(rs.getDouble("valor"));
recibosdetallestemporal.setCantidad(rs.getInt("cantidad"));
recibosdetallestemporal.setPago(rs.getDouble("pago"));
recibosdetallestemporal.setEsrecargo(rs.getString("esrecargo"));
recibosdetallestemporal.setSaldo(rs.getDouble("saldo"));
recibosdetallestemporal.setUsername(rs.getString("username"));
recibosdetallestemporal.setIdrecibesdetallestemporal(rs.getInt("idrecibesdetallestemporal"));
    }
    rs.close();
    psquery.close();
 return recibosdetallestemporal;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdrecibo()
*/

public static List<Recibosdetallestemporal> findByIdrecibo(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where idrecibo='"+recibosdetallestemporal.getIdrecibo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdmunicipio()
*/

public static List<Recibosdetallestemporal> findByIdmunicipio(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where idmunicipio='"+recibosdetallestemporal.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFecha()
*/

public static List<Recibosdetallestemporal> findByFecha(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where fecha='"+recibosdetallestemporal.getFecha()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdregimen()
*/

public static List<Recibosdetallestemporal> findByIdregimen(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where idregimen='"+recibosdetallestemporal.getIdregimen()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByDueno()
*/

public static List<Recibosdetallestemporal> findByDueno(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where dueno='"+recibosdetallestemporal.getDueno()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByValor()
*/

public static List<Recibosdetallestemporal> findByValor(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where valor='"+recibosdetallestemporal.getValor()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByCantidad()
*/

public static List<Recibosdetallestemporal> findByCantidad(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where cantidad='"+recibosdetallestemporal.getCantidad()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPago()
*/

public static List<Recibosdetallestemporal> findByPago(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where pago='"+recibosdetallestemporal.getPago()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByEsrecargo()
*/

public static List<Recibosdetallestemporal> findByEsrecargo(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where esrecargo='"+recibosdetallestemporal.getEsrecargo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findBySaldo()
*/

public static List<Recibosdetallestemporal> findBySaldo(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where saldo='"+recibosdetallestemporal.getSaldo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByUsername()
*/

public static List<Recibosdetallestemporal> findByUsername(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where username='"+recibosdetallestemporal.getUsername()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdrecibesdetallestemporal()
*/

public static List<Recibosdetallestemporal> findByIdrecibesdetallestemporal(Recibosdetallestemporal recibosdetallestemporal,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
      String sql = "select * from recibosdetallestemporal where idrecibesdetallestemporal='"+recibosdetallestemporal.getIdrecibesdetallestemporal()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Recibosdetallestemporal> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Recibosdetallestemporal>();
  String sql = "select * from recibosdetallestemporal";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from recibosdetallestemporal";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from recibosdetallestemporal where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from recibosdetallestemporal";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from recibosdetallestemporal where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Recibosdetallestemporal> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Recibosdetallestemporal>();
  String sql = "select * from recibosdetallestemporal where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Recibosdetallestemporal> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Recibosdetallestemporal>();
  String sql = "select * from recibosdetallestemporal";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "recibosdetallestemporal" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Recibosdetallestemporal recibosdetallestemporal2 = new Recibosdetallestemporal(
         rs.getInt("idrecibo"),rs.getString("idmunicipio"),rs.getDate("fecha"),rs.getString("idregimen"),rs.getString("dueno"),rs.getDouble("valor"),rs.getInt("cantidad"),rs.getDouble("pago"),rs.getString("esrecargo"),rs.getDouble("saldo"),rs.getString("username"),rs.getInt("idrecibesdetallestemporal"));
            
            
       list.add(recibosdetallestemporal2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
